package com.io.controller;

import com.io.constant.ApiResultEnum;
import com.io.dto.ApiResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

/**
 * The class/interface
 *
 * @author guodd
 * @version 1.0 use jdk 1.8
 */
@Api(tags = "全局")
@RestController
@RequestMapping(value = "/init")
public class InitController {

    @ApiOperation(value = "初始化数据")
    @GetMapping(value = "/doData")
    public ApiResult doData() {
        return ApiResult.ok();
    }

    @ApiOperation(value = "权限控制异常")
    @GetMapping(path = "/401")
    @ResponseStatus(HttpStatus.UNAUTHORIZED)
    public ApiResult unauthorized() {
        return ApiResult.error(ApiResultEnum.AUTHENTICATION_ERROR);
    }
}
